<template>
  <el-dialog v-dialogDrag :visible.sync="dialogVisible" :title="title" width="1000px">
    <button-group ref="buttonGroup" @cancel="dialogVisible = false" />
    <el-row>
      <div class="detailsTop">
        <span>维修任务单{{detailInfo.repairMethod == '1' ? '（内修）':'（外修）'}}</span>
        <el-divider content-position="right">{{ detailInfo.applyNo }}</el-divider>
      </div>
      <div class="detailCont detailDialogFont twoDetailStyle">
        <h1>基础信息</h1>
        <ul>
          <li>
            <b>申请单号</b>
            <span>{{ detailInfo.applyNo }}</span>
          </li>
          <li>
            <b>设备</b>
            <span>{{ detailInfo.equipName}}{{ detailInfo.equipCode ? '【' + detailInfo.equipCode + '】' : '' }}</span>
          </li>
          <li>
            <b>故障分类</b>
            <span>{{ detailInfo.classifyName }}</span>
          </li>
          <li>
            <b>故障发生时间</b>
            <span>{{ detailInfo.faultTime }}</span>
          </li>
          <li>
            <b>紧急度</b>
            <span>{{ detailInfo.emergency }}</span>
          </li>
          <li>
            <b>申请人</b>
            <span>{{ detailInfo.applyUserName }}</span>
          </li>
          <li>
            <b>所属部门</b>
            <span>{{ detailInfo.deptName }}</span>
          </li>
          <li class="oneHang">
            <b>故障描述</b>
            <span>{{ detailInfo.faultRemark }}</span>
          </li>
        </ul>
        <div v-if="detailInfo.status == '4'">
          <h1>维修信息</h1>
          <ul>
            <li>
              <b>确认人</b>
              <span>{{ detailInfo.confirmName }}</span>
            </li>
            <li>
              <b>确认时间</b>
              <span>{{ detailInfo.confirmTime }}</span>
            </li>
            <li>
              <b>维修公司</b>
              <span>{{ detailInfo.maintainCompany }}</span>
            </li>
            <li>
              <b>任务开始时间</b>
              <span>{{ detailInfo.startTime }}</span>
            </li>
            <li>
              <b>任务结束时间</b>
              <span>{{ detailInfo.endTime }}</span>
            </li>
            <li>
              <b>维修方式</b>
              <span>{{ detailInfo.repairMethod == '1' ? '内修':'外修' }}</span>
            </li>
            <li>
              <b>维修工时</b>
              <span>{{ detailInfo.repairHours }}</span>
            </li>
            <li>
              <b>维修成本</b>
              <span>{{ detailInfo.repairCost }}</span>
            </li>
            <li>
              <b>责任人</b>
              <span>{{ detailInfo.responsiblePersonName }}</span>
            </li>
            <li>
              <b>期望解决时间</b>
              <span>{{ detailInfo.expectedResolutionTime }}</span>
            </li>
            <li>
              <b>是否解决</b>
              <span>{{ detailInfo.isSolve == '1' ? '是':'否' }}</span>
            </li>
            <li class="oneHang">
              <b>说明</b>
              <span>{{ detailInfo.instructions }}</span>
            </li>
          </ul>
        </div>
        <p style="text-align:right;" v-if="detailInfo.status == '2'">
          <el-button type="primary" icon="el-icon-check" @click="startBtn">开始</el-button>
        </p>
      </div>
    </el-row>
  </el-dialog>
</template>

<script>
export default {
  props: {
    userAllList: {
      type: Array,
      default: () => {
        return []
      }
    }
  },
  data() {
    return {
      detailInfo: {},
      dialogVisible: false, // 对话框状态
      ruleForm: {
        expectedResolutionTime: '',
        id: '',
        maintainCompany: '',
        repairMethod: 1,
        responsiblePerson: '',
        confirmBy: ''
      },
      rules: {
        responsiblePerson: [
          { required: true, message: '责任人不能为空！', trigger: 'change' }
        ],
        expectedResolutionTime: [
          { required: true, message: '期望解决时间不能为空！', trigger: 'blur' }
        ],
        repairMethod: [
          { required: true, message: '维修方式不能为空！', trigger: 'change' }
        ],
        maintainCompany: [
          { required: false, message: '维修公司不能为空！', trigger: 'blur' }
        ],
        confirmBy: [
          { required: true, message: '确认人不能为空！', trigger: 'change' }
        ]
      },
      title: ''
    }
  },

  watch: {},

  mounted() {},

  methods: {
    async getInfo(row) {
      if (row.repairMethod)
        row.repairMethod == '1'
          ? (this.title = '内修-详情')
          : (this.title = '外修-详情')
      const res = await this.$axios.get(
        `/equip/repair/order/detail?id=${row.id}`
      )
      if (res && res.data.code === 200) {
        this.detailInfo = res.data.data
        this.dialogVisible = true
      }
    },
    /* 开始 */
    startBtn() {
      this.$confirm(`确认开始任务？`, '提示', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(async () => {
          const res = await this.$axios.post(
            `/equip/repair/order/task/start/${this.detailInfo.id}`
          )
          if (res.data.code === 200) {
            this.$notify.success('开始成功！')
            this.dialogVisible = false
            this.$emit('getTableInfo', 1)
          } else {
            this.$notify.error(res.data.msg)
          }
        })
        .catch(() => {})
    }
  }
}
</script>

<style lang='scss' scoped>
</style>

<style lang="scss">
</style>
